{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Conversational App for Itinerary Planning"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "from dotenv import load_dotenv\n",
    "#from langchain import HuggingFaceHub\n",
    "\n",
    "from langchain import PromptTemplate, LLMChain\n",
    "\n",
    "load_dotenv()\n",
    "\n",
    "#os.environ[\"HUGGINGFACEHUB_API_TOKEN\"]\n",
    "#retrieving api key\n",
    "key=os.environ['OPENAI_API_KEY']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "from langchain.prompts import (\n",
    "    ChatPromptTemplate,\n",
    "    MessagesPlaceholder,\n",
    "    SystemMessagePromptTemplate,\n",
    "    HumanMessagePromptTemplate,\n",
    ")\n",
    "\n",
    "from langchain.schema import (\n",
    "    AIMessage,\n",
    "    HumanMessage,\n",
    "    SystemMessage\n",
    ")\n",
    "\n",
    "from langchain.chains import LLMChain, ConversationChain  \n",
    "from langchain.chat_models import ChatOpenAI\n",
    "\n",
    "\n",
    "chat = ChatOpenAI()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Sample bot with no memory"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "AIMessage(content=\"In Rome, there are numerous attractions to visit. Here is an optimized itinerary for your 2-day trip:\\n\\nDay 1:\\n1. Start your day by visiting the Colosseum, an iconic symbol of Rome's ancient history.\\n2. Next, explore the Roman Forum, which was the heart of ancient Rome and is located right next to the Colosseum.\\n3. Afterward, head to the Pantheon, a well-preserved Roman temple that is now a church.\\n4. Take a stroll through the historic center and visit the Trevi Fountain, where you can throw a coin and make a wish.\\n5. Enjoy a delicious Italian lunch in one of the traditional trattorias in the area.\\n6. In the afternoon, visit the Vatican City, home to St. Peter's Basilica and the Vatican Museums. Don't miss the opportunity to see Michelangelo's famous Sistine Chapel.\\n7. End your day by exploring the charming neighborhood of Trastevere, known for its narrow streets, colorful buildings, and lively nightlife. Have dinner at one of the local restaurants.\\n\\nDay 2:\\n1. Start your day at the Spanish Steps, a popular meeting point in Rome.\\n2. From there, walk to the nearby Villa Borghese, a beautiful park where you can rent bikes or simply enjoy a leisurely stroll.\\n3. Visit the Borghese Gallery, located within the park, which houses an impressive collection of art and sculptures.\\n4. Afterward, head to Piazza Navona, a bustling square with beautiful fountains and impressive Baroque architecture. You can also find many outdoor cafes and street performers here.\\n5. Explore the charming neighborhood of Campo de' Fiori, known for its vibrant market during the day and lively nightlife in the evening.\\n6. In the afternoon, visit the iconic Trevi Fountain again, as it looks even more magical at night.\\n7. End your day by indulging in some delicious Italian cuisine at a traditional restaurant.\\n\\nRemember to wear comfortable shoes, as there will be a lot of walking involved. Enjoy your trip to Rome!\", additional_kwargs={}, example=False)"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from langchain.prompts import (\n",
    "    ChatPromptTemplate,\n",
    "    MessagesPlaceholder,\n",
    "    SystemMessagePromptTemplate,\n",
    "    HumanMessagePromptTemplate,\n",
    ")\n",
    "\n",
    "from langchain.schema import (\n",
    "    AIMessage,\n",
    "    HumanMessage,\n",
    "    SystemMessage\n",
    ")\n",
    "\n",
    "from langchain.chains import LLMChain, ConversationChain  \n",
    "from langchain.chat_models import ChatOpenAI\n",
    "\n",
    "from langchain.chat_models import ChatOpenAI\n",
    "\n",
    "chat = ChatOpenAI()\n",
    "messages = [\n",
    "    SystemMessage(content=\"You are a helpful assistant that help the user to plan an optimized itinerary.\"),\n",
    "    HumanMessage(content=\"I'm going to Rome for 2 days, what can I visit?\")\n",
    "]\n",
    "chat(messages)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "In Rome, there are many famous attractions to visit. Here's an optimized itinerary for your two-day trip:\n",
      "\n",
      "Day 1:\n",
      "1. Start your day by visiting the Colosseum, one of the world's most iconic ancient landmarks.\n",
      "2. Next, explore the nearby Roman Forum, an ancient Roman marketplace.\n",
      "3. Afterward, head to the Pantheon, a well-preserved Roman temple with a stunning dome.\n",
      "4. Take a stroll through the historic district of Trastevere, known for its charming streets and authentic Roman atmosphere.\n",
      "5. In the evening, visit the Trevi Fountain and toss a coin to ensure your return to Rome.\n",
      "\n",
      "Day 2:\n",
      "1. Begin your day at Vatican City, the smallest independent state in the world. Visit St. Peter's Basilica and admire Michelangelo's masterpiece, the Sistine Chapel.\n",
      "2. Explore the Vatican Museums, home to an extensive collection of art and historical artifacts.\n",
      "3. Enjoy a leisurely walk along the Tiber River and cross over to the picturesque neighborhood of Castel Sant'Angelo.\n",
      "4. Visit the Spanish Steps, a popular meeting point with a beautiful view of the city.\n",
      "5. End your day by exploring the charming neighborhood of Piazza Navona, known for its baroque architecture and lively atmosphere.\n",
      "\n",
      "Remember to check the opening hours and availability of tickets for the attractions in advance. Enjoy your trip to Rome!\n"
     ]
    }
   ],
   "source": [
    "output = chat(messages)\n",
    "print(output.content)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Adding Memory"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "\n",
      "\u001b[1m> Entering new ConversationChain chain...\u001b[0m\n",
      "Prompt after formatting:\n",
      "\u001b[32;1m\u001b[1;3mThe following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know.\n",
      "\n",
      "Current conversation:\n",
      "\n",
      "Human: Hi there!\n",
      "AI:\u001b[0m\n",
      "\n",
      "\u001b[1m> Finished chain.\u001b[0m\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'Hello! How can I assist you today?'"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from langchain.memory import ConversationBufferMemory\n",
    "from langchain.chains import ConversationChain  \n",
    "\n",
    "memory = ConversationBufferMemory()\n",
    "conversation = ConversationChain(\n",
    "    llm=chat, verbose=True, memory=memory\n",
    ")\n",
    "\n",
    "conversation.run(\"Hi there!\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "\n",
      "\u001b[1m> Entering new ConversationChain chain...\u001b[0m\n",
      "Prompt after formatting:\n",
      "\u001b[32;1m\u001b[1;3mThe following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know.\n",
      "\n",
      "Current conversation:\n",
      "Human: Hi there!\n",
      "AI: Hello! How can I assist you today?\n",
      "Human: what is the most iconic place in Rome?\n",
      "AI:\u001b[0m\n",
      "\n",
      "\u001b[1m> Finished chain.\u001b[0m\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'The most iconic place in Rome is probably the Colosseum. It is a magnificent amphitheater that was built in the first century AD and is one of the most recognizable symbols of ancient Rome. The Colosseum was used for gladiatorial contests, public spectacles, and other events. Today, it is a major tourist attraction and a UNESCO World Heritage site.'"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "conversation.run(\"what is the most iconic place in Rome?\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "\n",
      "\u001b[1m> Entering new ConversationChain chain...\u001b[0m\n",
      "Prompt after formatting:\n",
      "\u001b[32;1m\u001b[1;3mThe following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know.\n",
      "\n",
      "Current conversation:\n",
      "Human: Hi there!\n",
      "AI: Hello! How can I assist you today?\n",
      "Human: what is the most iconic place in Rome?\n",
      "AI: The most iconic place in Rome is probably the Colosseum. It is a magnificent amphitheater that was built in the first century AD and is one of the most recognizable symbols of ancient Rome. The Colosseum was used for gladiatorial contests, public spectacles, and other events. Today, it is a major tourist attraction and a UNESCO World Heritage site.\n",
      "Human: What kind of other events?\n",
      "AI:\u001b[0m\n",
      "\n",
      "\u001b[1m> Finished chain.\u001b[0m\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'Other events that took place at the Colosseum include mock sea battles, animal hunts, and reenactments of famous battles. The Colosseum was also used for executions and religious ceremonies. It was a versatile venue that could accommodate a variety of events and entertainments.'"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "conversation.run(\"What kind of other events?\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'history': 'Human: Hi there!\\nAI: Hello! How can I assist you today?\\nHuman: what is the most iconic place in Rome?\\nAI: The most iconic place in Rome is probably the Colosseum. It is a magnificent amphitheater that was built in the first century AD and is one of the most recognizable symbols of ancient Rome. The Colosseum was used for gladiatorial contests, public spectacles, and other events. Today, it is a major tourist attraction and a UNESCO World Heritage site.\\nHuman: What kind of other events?\\nAI: Other events that took place at the Colosseum include mock sea battles, animal hunts, and reenactments of famous battles. The Colosseum was also used for executions and religious ceremonies. It was a versatile venue that could accommodate a variety of events and entertainments.'}"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "memory.load_memory_variables({})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "from langchain.prompts import (\n",
    "    ChatPromptTemplate,\n",
    "    MessagesPlaceholder,\n",
    "    SystemMessagePromptTemplate,\n",
    "    HumanMessagePromptTemplate,\n",
    ")\n",
    "from langchain.memory import ConversationBufferMemory\n",
    "\n",
    "\n",
    "# LLM\n",
    "#repo_id = \"databricks/dolly-v2-3b\"\n",
    "#llm = HuggingFaceHub(\n",
    "#    repo_id=repo_id, model_kwargs={\"temperature\": 0.5, \"max_length\": 1000})\n",
    "# Prompt \n",
    "\n",
    "prompt = ChatPromptTemplate.from_messages(\n",
    "    messages=[\n",
    "        SystemMessagePromptTemplate.from_template(\n",
    "            \"You are a helpful assistant that help the user to plan an optimized itinerary.\"\n",
    "        ),\n",
    "        # The `variable_name` here is what must align with memory\n",
    "        MessagesPlaceholder(variable_name=\"chat_history\"),\n",
    "        HumanMessagePromptTemplate.from_template(\"{question}\")\n",
    "    ]\n",
    ")\n",
    "\n",
    "# Notice that we `return_messages=True` to fit into the MessagesPlaceholder\n",
    "# Notice that `\"chat_history\"` aligns with the MessagesPlaceholder name\n",
    "memory = ConversationBufferMemory(memory_key=\"chat_history\",return_messages=True)\n",
    "conversation = LLMChain(\n",
    "    llm=chat,\n",
    "    prompt=prompt,\n",
    "    verbose=False,\n",
    "    memory=memory\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "User:  hello\n",
      "AI system:  Hello! How can I assist you today?\n",
      "User:  I'm planning a 1-day trip in Venice. What should I visit?\n",
      "AI system:  That sounds like a wonderful plan! In Venice, there are several must-visit attractions that you can explore in a day. Here's a suggested itinerary for your 1-day trip in Venice:\n",
      "\n",
      "1. St. Mark's Square (Piazza San Marco): Start your day by visiting the iconic St. Mark's Square. Take a stroll and admire the stunning architecture of St. Mark's Basilica and the Doge's Palace. Don't forget to feed the pigeons in the square!\n",
      "\n",
      "2. Doge's Palace (Palazzo Ducale): Visit the Doge's Palace, located right next to St. Mark's Basilica. Explore the grand halls, the famous Bridge of Sighs, and the prison cells. Consider taking a guided tour to learn about the history and significance of this landmark.\n",
      "\n",
      "3. Rialto Bridge (Ponte di Rialto): Head towards the Rialto Bridge, one of the most famous bridges in Venice. Enjoy the picturesque views of the Grand Canal and explore the bustling Rialto Market nearby, where you can find fresh produce, seafood, and local specialties.\n",
      "\n",
      "4. Gondola Ride: Treat yourself to an unforgettable gondola ride through the narrow canals of Venice. It's a great way to experience the city from a different perspective and soak in the romantic atmosphere.\n",
      "\n",
      "5. Murano Island: Take a vaporetto (water bus) to Murano Island, famous for its glassmaking tradition. Visit a glass factory to witness skilled artisans creating beautiful glass pieces. You can also explore the island's charming streets and enjoy a leisurely lunch at one of the local restaurants.\n",
      "\n",
      "6. Burano Island: From Murano, continue your trip to Burano Island. Known for its colorful houses and lace-making tradition, Burano offers a vibrant and picturesque setting. Take a leisurely walk around the island, visit the lace shops, and capture some beautiful photos.\n",
      "\n",
      "7. Enjoy a Venetian Dinner: As the day comes to an end, head back to Venice and indulge in a delicious Venetian dinner. You can try some local specialties like seafood risotto, sarde in saor (marinated sardines), or fritto misto (mixed fried seafood) at one of the traditional trattorias or osterias.\n",
      "\n",
      "Remember, this is just a suggested itinerary, and you can customize it based on your personal preferences and interests. Enjoy your trip to Venice!\n",
      "User:  thanks! I'm planning to be around also the next day, and I love hiking. Do you have any suggestion nearby?\n",
      "AI system:  Certainly! If you enjoy hiking and want to explore the natural beauty around Venice, there are a few options you can consider for the next day:\n",
      "\n",
      "1. The Dolomites: Located about 2-3 hours away from Venice, the Dolomites offer breathtaking landscapes and incredible hiking opportunities. You can take a day trip to one of the towns in the Dolomites, such as Cortina d'Ampezzo or Belluno, and embark on a hiking adventure surrounded by majestic mountains and picturesque trails.\n",
      "\n",
      "2. Prosecco Hills: The Prosecco Hills, located about an hour north of Venice, are known for their vineyards and scenic countryside. You can explore the charming towns of Conegliano and Valdobbiadene and enjoy hiking through the vineyards while enjoying the stunning views. Don't miss the chance to taste some delicious Prosecco, the famous sparkling wine of the region.\n",
      "\n",
      "3. Colli Euganei: Located southwest of Venice, the Colli Euganei is a regional park with a volcanic landscape. It offers a variety of hiking trails through vineyards, olive groves, and thermal springs. You can visit the town of Arquà Petrarca, known for its medieval charm and as the final resting place of the poet Petrarch.\n",
      "\n",
      "4. Lagoon Islands: If you prefer a more relaxed hiking experience, you can explore the islands within the Venetian Lagoon. Islands like Lido, Sant'Erasmo, and Pellestrina offer scenic paths and peaceful landscapes, perfect for a leisurely hike away from the crowds of central Venice.\n",
      "\n",
      "Remember to check the weather conditions and plan your hiking trip accordingly. Additionally, consider the travel time and transportation options when selecting your hiking destination. Enjoy your hiking adventure near Venice!\n",
      "User:  which one is closer to Milan?\n",
      "AI system:  If you're looking for a hiking destination closer to Milan, the best option would be the Lombardy region, which surrounds Milan. Here are a couple of suggestions for hiking near Milan:\n",
      "\n",
      "1. Lake Como: Located just about an hour's drive from Milan, Lake Como is a stunning destination for hiking. The area offers a variety of trails that cater to different fitness levels. You can hike along the lakeshore, explore the charming towns like Bellagio and Varenna, and enjoy panoramic views of the lake and surrounding mountains.\n",
      "\n",
      "2. Bergamo: Bergamo is a picturesque town located about 45 minutes by train from Milan. It offers both historical and natural attractions. You can hike up to the old city walls and enjoy panoramic views of the town and the surrounding countryside. The nearby Parco dei Colli di Bergamo is also a great place for hiking with its lush greenery and well-marked trails.\n",
      "\n",
      "Both Lake Como and Bergamo are easily accessible from Milan, making them convenient options for a day trip or a short hiking excursion.\n"
     ]
    }
   ],
   "source": [
    "while True:\n",
    "    query = input('you: ')\n",
    "    if query == 'q':\n",
    "        break\n",
    "    output = conversation({\"question\": query})\n",
    "    print('User: ', query)\n",
    "    print('AI system: ', output['text'])\n",
    "    "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Adding non parametric knowledge"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "from langchain.llms import OpenAI\n",
    "from langchain.chat_models import ChatOpenAI\n",
    "from langchain.embeddings.openai import OpenAIEmbeddings\n",
    "from langchain.text_splitter import RecursiveCharacterTextSplitter\n",
    "from langchain.vectorstores import FAISS\n",
    "from langchain.document_loaders import PyPDFLoader\n",
    "\n",
    "import os\n",
    "\n",
    "from dotenv import load_dotenv\n",
    "\n",
    "load_dotenv()\n",
    "\n",
    "os.environ[\"OPENAI_API_KEY\"]\n",
    "\n",
    "text_splitter = RecursiveCharacterTextSplitter(\n",
    "            chunk_size=1500,\n",
    "            chunk_overlap=200\n",
    "        )\n",
    "\n",
    "raw_documents = PyPDFLoader('italy_travel.pdf').load()\n",
    "documents = text_splitter.split_documents(raw_documents)\n",
    "db = FAISS.from_documents(documents, OpenAIEmbeddings())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "\n",
      "\u001b[1m> Entering new StuffDocumentsChain chain...\u001b[0m\n",
      "\n",
      "\n",
      "\u001b[1m> Entering new LLMChain chain...\u001b[0m\n",
      "Prompt after formatting:\n",
      "\u001b[32;1m\u001b[1;3mSystem: Use the following pieces of context to answer the users question. \n",
      "If you don't know the answer, just say that you don't know, don't try to make up an answer.\n",
      "----------------\n",
      "cafes in the square. The most famous are the Quadri and\n",
      "Florian. \n",
      "Piazza San Marco, \n",
      "Venice\n",
      "4\n",
      "Historical Monuments\n",
      "Pantheon\n",
      " \n",
      "Miskita:\n",
      " \n",
      "\"Angelic and non-human design,\" was how\n",
      "Michelangelo described the Pantheon 14 centuries after its\n",
      "construction. The highlights are the gigantic dome, the upper\n",
      "eye, the sheer size of the place, and the harmony of the\n",
      "whole building. We visited with a Roman guide which is\n",
      "exactly how you should (or shouldn't) visit the city, especially\n",
      "since they talk too much and have lots and lots of history of\n",
      "each building. \n",
      "And so we learned things like how the interior\n",
      "dome was filled with sand during construction. Or not,\n",
      "because it really is impossible to be sure of anything when\n",
      "one doesn't know Italian and the guide has a very thick\n",
      "Roman accent. But we loved the place, especially the\n",
      "entrance portico with its stout columns. \n",
      " \n",
      "Almudena:\n",
      " \n",
      "The Pantheon is one of the best preserved\n",
      "ancient Roman monuments and it was the first classical\n",
      "building to be transformed into a church. In 608, the\n",
      "Byzantine Emperor Phocas offered it to Pope Boniface IV and\n",
      "☎\n",
      " 390 668 300 230\n",
      " - \n",
      "Piazza della Rotonda, \n",
      "Rome\n",
      "5\n",
      "Squares\n",
      "Piazza Navona\n",
      " \n",
      "Fernandoo:\n",
      " \n",
      "The Piazza Navona is one of the most\n",
      "famous squares in Rome. It's located east of the river not far\n",
      "from the Vatican. This is where the Stadium of Domitian was\n",
      "located in ancient times and if you view the area from above,\n",
      "you can still imagine the circular form of the arena. The\n",
      "\n",
      "can easily hear what guide says (so no need to stay with him to hear what he says) and you can walk around seeing the\n",
      "coliseum's most interesting points. While we waited for the time we were assigned, we could browse the exhibition which is\n",
      "located on the first floor. There were panels and models, all quite pleasant, which explained the history of the Colosseum and its\n",
      "various parts.\n",
      "Belén G. Bonorino:\n",
      " There is no more to say about the Roman Coliseum because it's virtually all been said. I simply advise\n",
      "you to go in the morning, half an hour before it opens to see the Colosseum without people - it's a gift that few can appreciate,\n",
      "especially when you see the sun coming through their holes, it's very good material for photos. I was there very early and the\n",
      "truth is that throughout my visit, which lasted an hour and three quarters, I took the best pictures of empty building. When I left this\n",
      "it was filling up.\n",
      "Ana Catarina Macedo:\n",
      " They freaking simulated sea battles in there and also fought lions and other sorts of animals for\n",
      "people's joy, no need to say anything about this place except it is awesome.\n",
      "1\n",
      "Historical Monuments\n",
      "☎\n",
      " 390 639 967 700\n",
      " - \n",
      "Piazza del Colosseo, \n",
      "Rome\n",
      "2\n",
      "Bridges\n",
      "Ponte Vecchio\n",
      " \n",
      "Sofia Santos:\n",
      " \n",
      "This is an important historical landmark,\n",
      "situated in the Italian city of Florence (Tuscany). The Ponte\n",
      "Vecchio is the only bridge in Florence that was not destroyed\n",
      "during the occupation of Italy in World War II, which it is said\n",
      "\n",
      "the spring with a dowsing rod and Agrippa ordering the construction of the aqueduct. \n",
      "Two other large statues tell of the benefits of\n",
      "this water: good health (the snake, still symbolic of pharmacies, was associated with Asclepius, the god of medicine), and the\n",
      "arrival of material goods (the cornucopia). Finally, Neptune is center-stage under a grand triumphal arch. The titan of the ocean\n",
      "brings to mind both Bernini and Michelangelo. On either side, winged sea horses dart furiously at onlookers. \n",
      "It's truly impressive.\n",
      "You'll want to sit and stay for a while, transfixed by the fountain’s beauty. \n",
      "Roberto Gonzalez:\n",
      " At first glance, it seems as if the fountain was built right in the very center of the city, but the reality is\n",
      "actually the opposite. All of the surrounding houses and palaces were intentionally built there to so that inhabitants could enjoy\n",
      "the fountain’s charms. \n",
      "And the fountain sure does have its charms. This fountain, which took 30 long years to build, collects a\n",
      "staggering 2,000 Euros a week from well-wishers, a sum which is collected by the city of Rome and directed toward the upkeep of\n",
      "the city’s fountains. \n",
      "There are dozens of complex allegories at the heart of the fountain but my favorites are the horses which\n",
      "reflect the states of the sea (raging, calm, stormy, etc.). \n",
      "One tip: be careful with pickpockets…they swarm around this famous\n",
      "fountain. \n",
      "Simona Budà:\n",
      "\n",
      "The forum hosts Temple of Romulus, Castor and\n",
      "Pollux, Saturn, Tito, Vespartino, Venus,and the Temple of Vesta. You will also have the chance to check out the Basilica of\n",
      "Maxentius, Basilica Aemilia, the arches of Titus and Septimius Severus, as well as a multitude of other important buildings. \n",
      "Maris:\n",
      " The remains of the Roman Forum are a testament to the once-grandiose capital of Imperial Rome. Today, the ruins\n",
      "are only crumbling relics but they hold an incalculable historic value. This was the nerve center of ancient Rome where they held\n",
      "all kinds of political, economic and social events. It’s located in a tourist area but it’s never too crowded for you to have a nice\n",
      "stroll through the ruins and, with a little imagination, find yourself in the city of a millennium ago. It’s a must-see when you’re in\n",
      "Rome. \n",
      "Ana Catarina Macedo:\n",
      " If you go by foot from Colosseum to Fontana Di Trevi you get o see some really cool stuff like that and\n",
      "if you're interested in archeology and history you'll just go nuts here.\n",
      "Raquel Mol:\n",
      " A must place to visit in Rome too.\n",
      "45\n",
      "Historical Monuments\n",
      "☎\n",
      " 39 060 608\n",
      " - \n",
      "Via della Salara Vecchia, 5/6, \n",
      "Rome\n",
      "46\n",
      "Squares\n",
      "Piazza del Campo\n",
      " \n",
      "Helen Atallah:\n",
      " \n",
      " \n",
      "Marta Jarpa Ruiz:\n",
      " \n",
      "If you can visit around August 17th,\n",
      "the experience will be 20 times better. This is one of the city's\n",
      "biggest festivals and to celebrate it they decorate their streets\n",
      "with medieval flags, the locals are in the streets with scarves\n",
      "Human: Give me some review about the Pantheon\u001b[0m\n",
      "\n",
      "\u001b[1m> Finished chain.\u001b[0m\n",
      "\n",
      "\u001b[1m> Finished chain.\u001b[0m\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'Miskita:\\n\"Angelic and non-human design,\" was how Michelangelo described the Pantheon 14 centuries after its construction. The highlights are the gigantic dome, the upper eye, the sheer size of the place, and the harmony of the whole building. We visited with a Roman guide which is exactly how you should (or shouldn\\'t) visit the city, especially since they talk too much and have lots and lots of history of each building. And so we learned things like how the interior dome was filled with sand during construction. Or not, because it really is impossible to be sure of anything when one doesn\\'t know Italian and the guide has a very thick Roman accent. But we loved the place, especially the entrance portico with its stout columns. \\n\\nAlmudena:\\nThe Pantheon is one of the best preserved ancient Roman monuments and it was the first classical building to be transformed into a church. In 608, the Byzantine Emperor Phocas offered it to Pope Boniface IV and it has been a place of Christian worship ever since. The interior of the Pantheon is breathtaking, with its massive dome and beautiful design. It\\'s definitely worth a visit if you\\'re in Rome.'"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from langchain.chains import ConversationalRetrievalChain\n",
    "from langchain.memory import ConversationBufferMemory\n",
    "\n",
    "memory = ConversationBufferMemory(\n",
    "            memory_key='chat_history',\n",
    "            return_messages=True\n",
    "        )\n",
    "\n",
    "llm = ChatOpenAI()\n",
    "qa_chain = ConversationalRetrievalChain.from_llm(llm, retriever=db.as_retriever(), memory=memory, verbose=True)\n",
    "qa_chain.run({'question':'Give me some review about the Pantheon'})\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "\n",
      "\u001b[1m> Entering new StuffDocumentsChain chain...\u001b[0m\n",
      "\n",
      "\n",
      "\u001b[1m> Entering new LLMChain chain...\u001b[0m\n",
      "Prompt after formatting:\n",
      "\u001b[32;1m\u001b[1;3mSystem: Use the following pieces of context to answer the users question. \n",
      "If you don't know the answer, just say that you don't know, don't try to make up an answer.\n",
      "----------------\n",
      "What to see\n",
      " in Italy\n",
      "Page 6\n",
      "Canals of Venice \n",
      "la peñita:\n",
      " To visit Venice in January is to discover another city different from that found on other occasions in July or August.\n",
      "Tourists (from myself included) inadvertently \"spoil\" the best views of the sites. If in summer the city is abuzz with activity, in winter\n",
      "it has a romantic touch that makes me like it even more, if possible. Getting lost in the alleys away from the sea of humanity,\n",
      "finding a niche with an carved image, a passageway under a building, or a hidden courtyard awaken in my mind an adventurous\n",
      "sensations which makes me like Venice most each time I visit. Also, you can get off the beaten track and mix it up with the\n",
      "inhabitants of the city and have drinks at places like \"Al diavolo with l'Aquasanta\" or \"La Taberna do mori\". You can go shopping\n",
      "stress-free, visit museums or palaces and get on and off the vaporettos at an unhurried pace. A real blast!\n",
      "Jaclyn Lombardo:\n",
      " As I walked the silence streets of Venice I heard the whispers of the past. Around every bend there was a\n",
      "story just waiting to be told. The boats lined the small weathered homes while the afternoon sun danced off the water. As I\n",
      "listened to the lapping of the water I began to daydream of years past when Venice was the wealthiest of nations. Marveling at it's\n",
      "newest architectural creations, smelling the sweet smells of spices, and hearing a lute player in the street while seeing couples\n",
      "\n",
      "ITALY\n",
      "MINUBE TRAVEL GUIDE\n",
      "The best must-see places for your travels, all\n",
      "discovered by real minube users. Enjoy!\n",
      "\n",
      "Alessia Polichetti:\n",
      " \n",
      "I suggest you to came in the south of\n",
      "this country, especially in Campania, where not only the food\n",
      "is. \n",
      " \n",
      "Tejdeep Yaramati:\n",
      " \n",
      "Seems like the best place to retire. \n",
      "Amalfi, \n",
      "Amalfi\n",
      "\n",
      "What to see\n",
      " in Italy\n",
      "Page 10\n",
      "58\n",
      "Gardens\n",
      "Parco Sempione\n",
      " \n",
      "Patricia M. Gómez:\n",
      " \n",
      "This is one of the most important\n",
      "parks in Milan. \n",
      "It was wonderful to visit it this winter all\n",
      "covered in snow and then this spring for our first \"picnic\". The\n",
      "park is very well kept and clean. \n",
      "You can easily go to\n",
      "workout, walk or just have a little taste of green space in this\n",
      "city, which can sometimes be gray. \n",
      "☎\n",
      " 390 277 404 343\n",
      " - \n",
      "Piazza Castello, 20121 Milan, Italy, \n",
      "Milan\n",
      "59\n",
      "Exhibitions\n",
      "Gulf of Naples\n",
      " \n",
      "Carlos Millán Gómez:\n",
      " \n",
      "Is there anywhere in the world\n",
      "more beautiful than the Gulf of Naples? I would say no. It is\n",
      "the very center of Paradise (perhaps it's also by the door of\n",
      "hell, yes, because Mount Vesuvius could erupt at any time).\n",
      "The Gulf smells like sea, lemon, fish, tomato ... and also\n",
      "sounds wonderful, due to Naples' Italian music. \"O sole mio\",\n",
      "\"Torna Surriento\", \"Questa picolissima serenade\" ... Want to\n",
      "know more about Neapolitan music? Well, come here, turn\n",
      "the speakers up and enjoy. http://bit.ly/qOEjiU \n",
      "Napoli, \n",
      "Naples\n",
      "60\n",
      "Historical Monuments\n",
      "Juliet's House (Casa di Giulietta)\n",
      " \n",
      "María Carmen García Moraleda:\n",
      " \n",
      "Verona is a pleasant\n",
      "place. The city itself is very nice and there is romance added\n",
      "thanks to the story of Romeo and Juliet, although the truth is\n",
      "that now it is not very touristy. \n",
      "Although if really what you\n",
      "want is love, poetry and verse, its marvellous. \n",
      " \n",
      "maya menozzi:\n",
      " \n",
      "it’s lovely to see lots of people writing\n",
      "Human: What can I visit in India?\u001b[0m\n",
      "\n",
      "\u001b[1m> Finished chain.\u001b[0m\n",
      "\n",
      "\u001b[1m> Finished chain.\u001b[0m\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "\"I'm sorry, but the given context does not provide any information about places to visit in India.\""
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from langchain.prompts.prompt import PromptTemplate\n",
    "\n",
    "custom_template = \"\"\"Given the following conversation and a follow up question, rephrase the follow up question to be a standalone question. \n",
    "If you cannot find the answer in the document provided, ignore the document and answer anyway.\n",
    "Chat History:\n",
    "{chat_history}\n",
    "Follow Up Input: {question}\n",
    "Standalone question:\"\"\"\n",
    "\n",
    "CUSTOM_QUESTION_PROMPT = PromptTemplate.from_template(custom_template)\n",
    "\n",
    "memory = ConversationBufferMemory(\n",
    "            memory_key='chat_history',\n",
    "            return_messages=True\n",
    "        )\n",
    "\n",
    "\n",
    "qa_chain = ConversationalRetrievalChain.from_llm(llm, retriever=db.as_retriever(), condense_question_prompt=CUSTOM_QUESTION_PROMPT, memory=memory, verbose=True)\n",
    "qa_chain.run({'question':'What can I visit in India?'})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [],
   "source": [
    "from langchain.agents.agent_toolkits import create_retriever_tool\n",
    "\n",
    "tool = create_retriever_tool(\n",
    "    db.as_retriever(), \n",
    "    \"italy_travel\",\n",
    "    \"Searches and returns documents regarding Italy.\"\n",
    ")\n",
    "tools = [tool]\n",
    "\n",
    "memory = ConversationBufferMemory(\n",
    "            memory_key='chat_history',\n",
    "            return_messages=True\n",
    "        )\n",
    "\n",
    "from langchain.agents.agent_toolkits import create_conversational_retrieval_agent\n",
    "\n",
    "from langchain.chat_models import ChatOpenAI\n",
    "llm = ChatOpenAI(temperature = 0)\n",
    "\n",
    "agent_executor = create_conversational_retrieval_agent(llm, tools, memory_key='chat_history', verbose=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "\n",
      "\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n",
      "\u001b[32;1m\u001b[1;3mHello Vale! How can I assist you today?\u001b[0m\n",
      "\n",
      "\u001b[1m> Finished chain.\u001b[0m\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'input': \"hi, i'm Vale\",\n",
       " 'chat_history': [HumanMessage(content=\"hi, i'm Vale\", additional_kwargs={}, example=False),\n",
       "  AIMessage(content='Hello Vale! How can I assist you today?', additional_kwargs={}, example=False)],\n",
       " 'output': 'Hello Vale! How can I assist you today?',\n",
       " 'intermediate_steps': []}"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "agent_executor({\"input\": \"hi, i'm Vale\"})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "\n",
      "\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n",
      "\u001b[32;1m\u001b[1;3m\n",
      "Invoking: `italy_travel` with `Pantheon`\n",
      "\n",
      "\n",
      "\u001b[0m\u001b[36;1m\u001b[1;3m[Document(page_content='cafes in the square. The most famous are the Quadri and\\nFlorian. \\nPiazza San Marco, \\nVenice\\n4\\nHistorical Monuments\\nPantheon\\n \\nMiskita:\\n \\n\"Angelic and non-human design,\" was how\\nMichelangelo described the Pantheon 14 centuries after its\\nconstruction. The highlights are the gigantic dome, the upper\\neye, the sheer size of the place, and the harmony of the\\nwhole building. We visited with a Roman guide which is\\nexactly how you should (or shouldn\\'t) visit the city, especially\\nsince they talk too much and have lots and lots of history of\\neach building. \\nAnd so we learned things like how the interior\\ndome was filled with sand during construction. Or not,\\nbecause it really is impossible to be sure of anything when\\none doesn\\'t know Italian and the guide has a very thick\\nRoman accent. But we loved the place, especially the\\nentrance portico with its stout columns. \\n \\nAlmudena:\\n \\nThe Pantheon is one of the best preserved\\nancient Roman monuments and it was the first classical\\nbuilding to be transformed into a church. In 608, the\\nByzantine Emperor Phocas offered it to Pope Boniface IV and\\n☎\\n 390 668 300 230\\n - \\nPiazza della Rotonda, \\nRome\\n5\\nSquares\\nPiazza Navona\\n \\nFernandoo:\\n \\nThe Piazza Navona is one of the most\\nfamous squares in Rome. It\\'s located east of the river not far\\nfrom the Vatican. This is where the Stadium of Domitian was\\nlocated in ancient times and if you view the area from above,\\nyou can still imagine the circular form of the arena. The', metadata={'source': 'italy_travel.pdf', 'page': 2}), Document(page_content=\"the spring with a dowsing rod and Agrippa ordering the construction of the aqueduct. \\nTwo other large statues tell of the benefits of\\nthis water: good health (the snake, still symbolic of pharmacies, was associated with Asclepius, the god of medicine), and the\\narrival of material goods (the cornucopia). Finally, Neptune is center-stage under a grand triumphal arch. The titan of the ocean\\nbrings to mind both Bernini and Michelangelo. On either side, winged sea horses dart furiously at onlookers. \\nIt's truly impressive.\\nYou'll want to sit and stay for a while, transfixed by the fountain’s beauty. \\nRoberto Gonzalez:\\n At first glance, it seems as if the fountain was built right in the very center of the city, but the reality is\\nactually the opposite. All of the surrounding houses and palaces were intentionally built there to so that inhabitants could enjoy\\nthe fountain’s charms. \\nAnd the fountain sure does have its charms. This fountain, which took 30 long years to build, collects a\\nstaggering 2,000 Euros a week from well-wishers, a sum which is collected by the city of Rome and directed toward the upkeep of\\nthe city’s fountains. \\nThere are dozens of complex allegories at the heart of the fountain but my favorites are the horses which\\nreflect the states of the sea (raging, calm, stormy, etc.). \\nOne tip: be careful with pickpockets…they swarm around this famous\\nfountain. \\nSimona Budà:\", metadata={'source': 'italy_travel.pdf', 'page': 4}), Document(page_content='about 135m. wide and 81m. tall (including the chariots that\\nadorn the towers on both sides). \\nWhen you climb the steps,\\nthere’s a great equestrian statue of the King. To the right,\\nthere is the Tomb of the Unknown Soldier of WWI with an\\neternal flame and two soldiers standing permanent guard It\\nalso offers exception views of Rome, a fact which makes the\\ntiring climb worthwhile. Although the monument was very\\ncontroversial in its day and has received all kinds of\\nhumorous and derogatory nicknames over the years (the\\nAllies famously called it the \"typewriter\" when they entered\\nRome in 1944), it is still one of the most-visited monuments in\\nthe city after the Vatican and the Roman Ruins. \\nThe base\\n☎\\n 39 066 780 664\\n - \\nPiazza Venezia, \\nRome\\n10\\nSquares\\nPiazza del Popolo\\n \\nTrotamundos:\\n \\nThe Piazza del Popolo is one of the most\\nfamous squares in Rome and its name means \"the People\\'s\\nSquare.\" It’s located at the north gate of the Aurelian walls\\nwhere the Porta Flaminia once marked the beginning of the\\nVia Flaminia, the main northern road during Imperial times.\\nThe square currently has a neoclassical look thanks to\\narchitect Giusseppe Valadier who redesigned it from 1811-\\n1822. If you look at the square from the north, there are three\\nmain streets which sprout from the square in trident shape:\\nVia del Corso in the center, Via del Babuino on the left, and\\nthe Via di Ripetta to the right. The twin churches of Santa\\nMaría dei Miracoli (1681) and Santa Maria in Montesanto', metadata={'source': 'italy_travel.pdf', 'page': 3}), Document(page_content=\"reflect the states of the sea (raging, calm, stormy, etc.). \\nOne tip: be careful with pickpockets…they swarm around this famous\\nfountain. \\nSimona Budà:\\n If there’s the first time here, you must throw a coin in the fountain and while you’re throwing the coin, you have\\nto make a wish. It’s a crowded destination, but it’s worth it!\\nAmy Pickard :\\n Absolutely beautiful attraction. Went back for a second visit before we left. Only downside was the huge\\namount of people around the attraction so was hard to get around. \\nJoshua B.:\\n Trevi fountain was amazing. My favorite sight in Rome.\\n16\\nHistorical Monuments\\n☎\\n 327 687 259\\n - \\nVia delle Muratte, 90, \\nRome\\n17\\nHistorical Monuments\\nArch of Constantine\\n \\nAlmudena:\\n \\nFor me, this is the most impressive arch in\\nRome. It's located on a road between Caelian Hill and\\nPalatine Hill where they once celebrated victory marches. It's\\n21 meters high, 26 meters wide, and more than 7 meters\\nthick. It was built in 315AD to celebrate the 10th anniversary\\nof the reign of Constantine and his victory over Maxentius at\\nthe Battle of the Milvian Bridge in 312AD. A restoration took\\nplace in 1804 and it is now decorated with medallions.\\nConstantine I is considered to be the first Christian Emperor\\nsince he converted to Christianity on his deathbed. This arch,\\nhowever, makes no reference to this. The bottom of the arch\\nis built from blocks of marble and the upper part is brick with\\nmarble trim. As far as the decoration goes, it's in accordance\", metadata={'source': 'italy_travel.pdf', 'page': 4})]\u001b[0m\u001b[32;1m\u001b[1;3mThe Pantheon is one of the best-preserved ancient Roman monuments located in Rome, Italy. It was originally built as a temple dedicated to all the gods of ancient Rome. The Pantheon is known for its impressive architecture, particularly its gigantic dome, which is one of the largest unreinforced concrete domes in the world. The dome has a central opening called the oculus, which allows natural light to enter the building.\n",
      "\n",
      "The Pantheon has a circular portico with stout columns and a grand entrance. Inside, the harmony of the whole building is remarkable. The interior dome was filled with sand during construction, and the building has been transformed into a church over the centuries.\n",
      "\n",
      "Visiting the Pantheon with a Roman guide is recommended as they can provide historical insights and interesting facts about the building. The Pantheon is a popular tourist attraction and a significant historical monument in Rome.\n",
      "\n",
      "Please note that the information provided is based on the available documents regarding Italy travel.\u001b[0m\n",
      "\n",
      "\u001b[1m> Finished chain.\u001b[0m\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'input': 'Tell me something about Pantheon',\n",
       " 'chat_history': [HumanMessage(content=\"hi, i'm Vale\", additional_kwargs={}, example=False),\n",
       "  AIMessage(content='Hello Vale! How can I assist you today?', additional_kwargs={}, example=False),\n",
       "  HumanMessage(content='Tell me something about Pantheon', additional_kwargs={}, example=False),\n",
       "  AIMessage(content='', additional_kwargs={'function_call': {'name': 'italy_travel', 'arguments': '{\\n  \"__arg1\": \"Pantheon\"\\n}'}}, example=False),\n",
       "  FunctionMessage(content='[Document(page_content=\\'cafes in the square. The most famous are the Quadri and\\\\nFlorian. \\\\nPiazza San Marco, \\\\nVenice\\\\n4\\\\nHistorical Monuments\\\\nPantheon\\\\n \\\\nMiskita:\\\\n \\\\n\"Angelic and non-human design,\" was how\\\\nMichelangelo described the Pantheon 14 centuries after its\\\\nconstruction. The highlights are the gigantic dome, the upper\\\\neye, the sheer size of the place, and the harmony of the\\\\nwhole building. We visited with a Roman guide which is\\\\nexactly how you should (or shouldn\\\\\\'t) visit the city, especially\\\\nsince they talk too much and have lots and lots of history of\\\\neach building. \\\\nAnd so we learned things like how the interior\\\\ndome was filled with sand during construction. Or not,\\\\nbecause it really is impossible to be sure of anything when\\\\none doesn\\\\\\'t know Italian and the guide has a very thick\\\\nRoman accent. But we loved the place, especially the\\\\nentrance portico with its stout columns. \\\\n \\\\nAlmudena:\\\\n \\\\nThe Pantheon is one of the best preserved\\\\nancient Roman monuments and it was the first classical\\\\nbuilding to be transformed into a church. In 608, the\\\\nByzantine Emperor Phocas offered it to Pope Boniface IV and\\\\n☎\\\\n 390 668 300 230\\\\n - \\\\nPiazza della Rotonda, \\\\nRome\\\\n5\\\\nSquares\\\\nPiazza Navona\\\\n \\\\nFernandoo:\\\\n \\\\nThe Piazza Navona is one of the most\\\\nfamous squares in Rome. It\\\\\\'s located east of the river not far\\\\nfrom the Vatican. This is where the Stadium of Domitian was\\\\nlocated in ancient times and if you view the area from above,\\\\nyou can still imagine the circular form of the arena. The\\', metadata={\\'source\\': \\'italy_travel.pdf\\', \\'page\\': 2}), Document(page_content=\"the spring with a dowsing rod and Agrippa ordering the construction of the aqueduct. \\\\nTwo other large statues tell of the benefits of\\\\nthis water: good health (the snake, still symbolic of pharmacies, was associated with Asclepius, the god of medicine), and the\\\\narrival of material goods (the cornucopia). Finally, Neptune is center-stage under a grand triumphal arch. The titan of the ocean\\\\nbrings to mind both Bernini and Michelangelo. On either side, winged sea horses dart furiously at onlookers. \\\\nIt\\'s truly impressive.\\\\nYou\\'ll want to sit and stay for a while, transfixed by the fountain’s beauty. \\\\nRoberto Gonzalez:\\\\n At first glance, it seems as if the fountain was built right in the very center of the city, but the reality is\\\\nactually the opposite. All of the surrounding houses and palaces were intentionally built there to so that inhabitants could enjoy\\\\nthe fountain’s charms. \\\\nAnd the fountain sure does have its charms. This fountain, which took 30 long years to build, collects a\\\\nstaggering 2,000 Euros a week from well-wishers, a sum which is collected by the city of Rome and directed toward the upkeep of\\\\nthe city’s fountains. \\\\nThere are dozens of complex allegories at the heart of the fountain but my favorites are the horses which\\\\nreflect the states of the sea (raging, calm, stormy, etc.). \\\\nOne tip: be careful with pickpockets…they swarm around this famous\\\\nfountain. \\\\nSimona Budà:\", metadata={\\'source\\': \\'italy_travel.pdf\\', \\'page\\': 4}), Document(page_content=\\'about 135m. wide and 81m. tall (including the chariots that\\\\nadorn the towers on both sides). \\\\nWhen you climb the steps,\\\\nthere’s a great equestrian statue of the King. To the right,\\\\nthere is the Tomb of the Unknown Soldier of WWI with an\\\\neternal flame and two soldiers standing permanent guard It\\\\nalso offers exception views of Rome, a fact which makes the\\\\ntiring climb worthwhile. Although the monument was very\\\\ncontroversial in its day and has received all kinds of\\\\nhumorous and derogatory nicknames over the years (the\\\\nAllies famously called it the \"typewriter\" when they entered\\\\nRome in 1944), it is still one of the most-visited monuments in\\\\nthe city after the Vatican and the Roman Ruins. \\\\nThe base\\\\n☎\\\\n 39 066 780 664\\\\n - \\\\nPiazza Venezia, \\\\nRome\\\\n10\\\\nSquares\\\\nPiazza del Popolo\\\\n \\\\nTrotamundos:\\\\n \\\\nThe Piazza del Popolo is one of the most\\\\nfamous squares in Rome and its name means \"the People\\\\\\'s\\\\nSquare.\" It’s located at the north gate of the Aurelian walls\\\\nwhere the Porta Flaminia once marked the beginning of the\\\\nVia Flaminia, the main northern road during Imperial times.\\\\nThe square currently has a neoclassical look thanks to\\\\narchitect Giusseppe Valadier who redesigned it from 1811-\\\\n1822. If you look at the square from the north, there are three\\\\nmain streets which sprout from the square in trident shape:\\\\nVia del Corso in the center, Via del Babuino on the left, and\\\\nthe Via di Ripetta to the right. The twin churches of Santa\\\\nMaría dei Miracoli (1681) and Santa Maria in Montesanto\\', metadata={\\'source\\': \\'italy_travel.pdf\\', \\'page\\': 3}), Document(page_content=\"reflect the states of the sea (raging, calm, stormy, etc.). \\\\nOne tip: be careful with pickpockets…they swarm around this famous\\\\nfountain. \\\\nSimona Budà:\\\\n If there’s the first time here, you must throw a coin in the fountain and while you’re throwing the coin, you have\\\\nto make a wish. It’s a crowded destination, but it’s worth it!\\\\nAmy Pickard :\\\\n Absolutely beautiful attraction. Went back for a second visit before we left. Only downside was the huge\\\\namount of people around the attraction so was hard to get around. \\\\nJoshua B.:\\\\n Trevi fountain was amazing. My favorite sight in Rome.\\\\n16\\\\nHistorical Monuments\\\\n☎\\\\n 327 687 259\\\\n - \\\\nVia delle Muratte, 90, \\\\nRome\\\\n17\\\\nHistorical Monuments\\\\nArch of Constantine\\\\n \\\\nAlmudena:\\\\n \\\\nFor me, this is the most impressive arch in\\\\nRome. It\\'s located on a road between Caelian Hill and\\\\nPalatine Hill where they once celebrated victory marches. It\\'s\\\\n21 meters high, 26 meters wide, and more than 7 meters\\\\nthick. It was built in 315AD to celebrate the 10th anniversary\\\\nof the reign of Constantine and his victory over Maxentius at\\\\nthe Battle of the Milvian Bridge in 312AD. A restoration took\\\\nplace in 1804 and it is now decorated with medallions.\\\\nConstantine I is considered to be the first Christian Emperor\\\\nsince he converted to Christianity on his deathbed. This arch,\\\\nhowever, makes no reference to this. The bottom of the arch\\\\nis built from blocks of marble and the upper part is brick with\\\\nmarble trim. As far as the decoration goes, it\\'s in accordance\", metadata={\\'source\\': \\'italy_travel.pdf\\', \\'page\\': 4})]', additional_kwargs={}, name='italy_travel'),\n",
       "  AIMessage(content='The Pantheon is one of the best-preserved ancient Roman monuments located in Rome, Italy. It was originally built as a temple dedicated to all the gods of ancient Rome. The Pantheon is known for its impressive architecture, particularly its gigantic dome, which is one of the largest unreinforced concrete domes in the world. The dome has a central opening called the oculus, which allows natural light to enter the building.\\n\\nThe Pantheon has a circular portico with stout columns and a grand entrance. Inside, the harmony of the whole building is remarkable. The interior dome was filled with sand during construction, and the building has been transformed into a church over the centuries.\\n\\nVisiting the Pantheon with a Roman guide is recommended as they can provide historical insights and interesting facts about the building. The Pantheon is a popular tourist attraction and a significant historical monument in Rome.\\n\\nPlease note that the information provided is based on the available documents regarding Italy travel.', additional_kwargs={}, example=False)],\n",
       " 'output': 'The Pantheon is one of the best-preserved ancient Roman monuments located in Rome, Italy. It was originally built as a temple dedicated to all the gods of ancient Rome. The Pantheon is known for its impressive architecture, particularly its gigantic dome, which is one of the largest unreinforced concrete domes in the world. The dome has a central opening called the oculus, which allows natural light to enter the building.\\n\\nThe Pantheon has a circular portico with stout columns and a grand entrance. Inside, the harmony of the whole building is remarkable. The interior dome was filled with sand during construction, and the building has been transformed into a church over the centuries.\\n\\nVisiting the Pantheon with a Roman guide is recommended as they can provide historical insights and interesting facts about the building. The Pantheon is a popular tourist attraction and a significant historical monument in Rome.\\n\\nPlease note that the information provided is based on the available documents regarding Italy travel.',\n",
       " 'intermediate_steps': [(_FunctionsAgentAction(tool='italy_travel', tool_input='Pantheon', log='\\nInvoking: `italy_travel` with `Pantheon`\\n\\n\\n', message_log=[AIMessage(content='', additional_kwargs={'function_call': {'name': 'italy_travel', 'arguments': '{\\n  \"__arg1\": \"Pantheon\"\\n}'}}, example=False)]),\n",
       "   [Document(page_content='cafes in the square. The most famous are the Quadri and\\nFlorian. \\nPiazza San Marco, \\nVenice\\n4\\nHistorical Monuments\\nPantheon\\n \\nMiskita:\\n \\n\"Angelic and non-human design,\" was how\\nMichelangelo described the Pantheon 14 centuries after its\\nconstruction. The highlights are the gigantic dome, the upper\\neye, the sheer size of the place, and the harmony of the\\nwhole building. We visited with a Roman guide which is\\nexactly how you should (or shouldn\\'t) visit the city, especially\\nsince they talk too much and have lots and lots of history of\\neach building. \\nAnd so we learned things like how the interior\\ndome was filled with sand during construction. Or not,\\nbecause it really is impossible to be sure of anything when\\none doesn\\'t know Italian and the guide has a very thick\\nRoman accent. But we loved the place, especially the\\nentrance portico with its stout columns. \\n \\nAlmudena:\\n \\nThe Pantheon is one of the best preserved\\nancient Roman monuments and it was the first classical\\nbuilding to be transformed into a church. In 608, the\\nByzantine Emperor Phocas offered it to Pope Boniface IV and\\n☎\\n 390 668 300 230\\n - \\nPiazza della Rotonda, \\nRome\\n5\\nSquares\\nPiazza Navona\\n \\nFernandoo:\\n \\nThe Piazza Navona is one of the most\\nfamous squares in Rome. It\\'s located east of the river not far\\nfrom the Vatican. This is where the Stadium of Domitian was\\nlocated in ancient times and if you view the area from above,\\nyou can still imagine the circular form of the arena. The', metadata={'source': 'italy_travel.pdf', 'page': 2}),\n",
       "    Document(page_content=\"the spring with a dowsing rod and Agrippa ordering the construction of the aqueduct. \\nTwo other large statues tell of the benefits of\\nthis water: good health (the snake, still symbolic of pharmacies, was associated with Asclepius, the god of medicine), and the\\narrival of material goods (the cornucopia). Finally, Neptune is center-stage under a grand triumphal arch. The titan of the ocean\\nbrings to mind both Bernini and Michelangelo. On either side, winged sea horses dart furiously at onlookers. \\nIt's truly impressive.\\nYou'll want to sit and stay for a while, transfixed by the fountain’s beauty. \\nRoberto Gonzalez:\\n At first glance, it seems as if the fountain was built right in the very center of the city, but the reality is\\nactually the opposite. All of the surrounding houses and palaces were intentionally built there to so that inhabitants could enjoy\\nthe fountain’s charms. \\nAnd the fountain sure does have its charms. This fountain, which took 30 long years to build, collects a\\nstaggering 2,000 Euros a week from well-wishers, a sum which is collected by the city of Rome and directed toward the upkeep of\\nthe city’s fountains. \\nThere are dozens of complex allegories at the heart of the fountain but my favorites are the horses which\\nreflect the states of the sea (raging, calm, stormy, etc.). \\nOne tip: be careful with pickpockets…they swarm around this famous\\nfountain. \\nSimona Budà:\", metadata={'source': 'italy_travel.pdf', 'page': 4}),\n",
       "    Document(page_content='about 135m. wide and 81m. tall (including the chariots that\\nadorn the towers on both sides). \\nWhen you climb the steps,\\nthere’s a great equestrian statue of the King. To the right,\\nthere is the Tomb of the Unknown Soldier of WWI with an\\neternal flame and two soldiers standing permanent guard It\\nalso offers exception views of Rome, a fact which makes the\\ntiring climb worthwhile. Although the monument was very\\ncontroversial in its day and has received all kinds of\\nhumorous and derogatory nicknames over the years (the\\nAllies famously called it the \"typewriter\" when they entered\\nRome in 1944), it is still one of the most-visited monuments in\\nthe city after the Vatican and the Roman Ruins. \\nThe base\\n☎\\n 39 066 780 664\\n - \\nPiazza Venezia, \\nRome\\n10\\nSquares\\nPiazza del Popolo\\n \\nTrotamundos:\\n \\nThe Piazza del Popolo is one of the most\\nfamous squares in Rome and its name means \"the People\\'s\\nSquare.\" It’s located at the north gate of the Aurelian walls\\nwhere the Porta Flaminia once marked the beginning of the\\nVia Flaminia, the main northern road during Imperial times.\\nThe square currently has a neoclassical look thanks to\\narchitect Giusseppe Valadier who redesigned it from 1811-\\n1822. If you look at the square from the north, there are three\\nmain streets which sprout from the square in trident shape:\\nVia del Corso in the center, Via del Babuino on the left, and\\nthe Via di Ripetta to the right. The twin churches of Santa\\nMaría dei Miracoli (1681) and Santa Maria in Montesanto', metadata={'source': 'italy_travel.pdf', 'page': 3}),\n",
       "    Document(page_content=\"reflect the states of the sea (raging, calm, stormy, etc.). \\nOne tip: be careful with pickpockets…they swarm around this famous\\nfountain. \\nSimona Budà:\\n If there’s the first time here, you must throw a coin in the fountain and while you’re throwing the coin, you have\\nto make a wish. It’s a crowded destination, but it’s worth it!\\nAmy Pickard :\\n Absolutely beautiful attraction. Went back for a second visit before we left. Only downside was the huge\\namount of people around the attraction so was hard to get around. \\nJoshua B.:\\n Trevi fountain was amazing. My favorite sight in Rome.\\n16\\nHistorical Monuments\\n☎\\n 327 687 259\\n - \\nVia delle Muratte, 90, \\nRome\\n17\\nHistorical Monuments\\nArch of Constantine\\n \\nAlmudena:\\n \\nFor me, this is the most impressive arch in\\nRome. It's located on a road between Caelian Hill and\\nPalatine Hill where they once celebrated victory marches. It's\\n21 meters high, 26 meters wide, and more than 7 meters\\nthick. It was built in 315AD to celebrate the 10th anniversary\\nof the reign of Constantine and his victory over Maxentius at\\nthe Battle of the Milvian Bridge in 312AD. A restoration took\\nplace in 1804 and it is now decorated with medallions.\\nConstantine I is considered to be the first Christian Emperor\\nsince he converted to Christianity on his deathbed. This arch,\\nhowever, makes no reference to this. The bottom of the arch\\nis built from blocks of marble and the upper part is brick with\\nmarble trim. As far as the decoration goes, it's in accordance\", metadata={'source': 'italy_travel.pdf', 'page': 4})])]}"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "agent_executor({\"input\": \"Tell me something about Pantheon\"})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "\n",
      "\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n",
      "\u001b[32;1m\u001b[1;3mIn India, there are numerous incredible places to visit, each with its own unique attractions and cultural experiences. While three days is a relatively short time to explore such a vast and diverse country, here are a few suggestions for places you can visit:\n",
      "\n",
      "1. Delhi: Start your trip in the capital city of India, Delhi. Spend a day exploring the historical sites in Old Delhi, such as the Red Fort, Jama Masjid, and Chandni Chowk. In New Delhi, visit iconic landmarks like India Gate, Qutub Minar, and Humayun's Tomb. Don't miss the opportunity to try delicious street food in Delhi.\n",
      "\n",
      "2. Agra: From Delhi, take a day trip to Agra, home to the magnificent Taj Mahal. Marvel at the beauty of this UNESCO World Heritage Site, known as one of the Seven Wonders of the World. Explore the Agra Fort, another impressive Mughal-era monument, and enjoy the local cuisine.\n",
      "\n",
      "3. Jaipur: Travel to Jaipur, the capital city of the colorful state of Rajasthan. Spend a day exploring the stunning Amber Fort, known for its intricate architecture and panoramic views. Visit the City Palace, Hawa Mahal (Palace of Winds), and Jantar Mantar, an astronomical observatory. Don't forget to indulge in Rajasthani cuisine and shop for traditional handicrafts.\n",
      "\n",
      "Please note that these are just a few suggestions, and India has many more incredible destinations to explore. It's advisable to plan your itinerary based on your interests and the specific region you wish to visit. Additionally, consider the travel time between cities and the availability of flights or trains to optimize your time.\u001b[0m\n",
      "\n",
      "\u001b[1m> Finished chain.\u001b[0m\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "\"In India, there are numerous incredible places to visit, each with its own unique attractions and cultural experiences. While three days is a relatively short time to explore such a vast and diverse country, here are a few suggestions for places you can visit:\\n\\n1. Delhi: Start your trip in the capital city of India, Delhi. Spend a day exploring the historical sites in Old Delhi, such as the Red Fort, Jama Masjid, and Chandni Chowk. In New Delhi, visit iconic landmarks like India Gate, Qutub Minar, and Humayun's Tomb. Don't miss the opportunity to try delicious street food in Delhi.\\n\\n2. Agra: From Delhi, take a day trip to Agra, home to the magnificent Taj Mahal. Marvel at the beauty of this UNESCO World Heritage Site, known as one of the Seven Wonders of the World. Explore the Agra Fort, another impressive Mughal-era monument, and enjoy the local cuisine.\\n\\n3. Jaipur: Travel to Jaipur, the capital city of the colorful state of Rajasthan. Spend a day exploring the stunning Amber Fort, known for its intricate architecture and panoramic views. Visit the City Palace, Hawa Mahal (Palace of Winds), and Jantar Mantar, an astronomical observatory. Don't forget to indulge in Rajasthani cuisine and shop for traditional handicrafts.\\n\\nPlease note that these are just a few suggestions, and India has many more incredible destinations to explore. It's advisable to plan your itinerary based on your interests and the specific region you wish to visit. Additionally, consider the travel time between cities and the availability of flights or trains to optimize your time.\""
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "output = agent_executor({\"input\": \"what can I visit in India in 3 days?\"})\n",
    "output['output']"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Adding external tools"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [],
   "source": [
    "from langchain import SerpAPIWrapper\n",
    "from langchain.agents import AgentType, initialize_agent\n",
    "from langchain.llms import OpenAI\n",
    "from langchain.tools import BaseTool, StructuredTool, Tool, tool\n",
    "\n",
    "import os\n",
    "from dotenv import load_dotenv\n",
    "\n",
    "load_dotenv()\n",
    "\n",
    "key = os.environ[\"SERPAPI_API_KEY\"]\n",
    "\n",
    "search = SerpAPIWrapper()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "tools = [\n",
    "    Tool.from_function(\n",
    "        func=search.run,\n",
    "        name=\"Search\",\n",
    "        description=\"useful for when you need to answer questions about current events\"\n",
    "    ),\n",
    "    create_retriever_tool(\n",
    "        db.as_retriever(), \n",
    "        \"italy_travel\",\n",
    "        \"Searches and returns documents regarding Italy.\"\n",
    "    )\n",
    "    ]\n",
    "\n",
    "agent_executor = create_conversational_retrieval_agent(llm, tools, memory_key='chat_history', verbose=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "ConversationBufferMemory(chat_memory=ChatMessageHistory(messages=[HumanMessage(content='Give me some review about the Pantheon', additional_kwargs={}, example=False), AIMessage(content='Miskita:\\n\"Angelic and non-human design,\" was how Michelangelo described the Pantheon 14 centuries after its construction. The highlights are the gigantic dome, the upper eye, the sheer size of the place, and the harmony of the whole building. We visited with a Roman guide which is exactly how you should (or shouldn\\'t) visit the city, especially since they talk too much and have lots and lots of history of each building. And so we learned things like how the interior dome was filled with sand during construction. Or not, because it really is impossible to be sure of anything when one doesn\\'t know Italian and the guide has a very thick Roman accent. But we loved the place, especially the entrance portico with its stout columns. \\n\\nAlmudena:\\nThe Pantheon is one of the best preserved ancient Roman monuments and it was the first classical building to be transformed into a church. In 608, the Byzantine Emperor Phocas offered it to Pope Boniface IV and it has been a place of Christian worship ever since. The interior of the Pantheon is breathtaking, with its massive dome and beautiful design. It\\'s definitely worth a visit if you\\'re in Rome.', additional_kwargs={}, example=False)]), output_key=None, input_key=None, return_messages=True, human_prefix='Human', ai_prefix='AI', memory_key='chat_history')"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "memory"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "\n",
      "\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n",
      "\u001b[32;1m\u001b[1;3mIndia is a vast and diverse country with numerous attractions to explore. While it may be challenging to cover all the highlights in just three days, here are some popular destinations that you can consider visiting:\n",
      "\n",
      "1. Delhi: Start your trip in the capital city of India, Delhi. Spend a day exploring the historical sites such as the Red Fort, Jama Masjid, Qutub Minar, and Humayun's Tomb. Don't miss a visit to the bustling markets of Chandni Chowk and indulge in delicious street food.\n",
      "\n",
      "2. Agra: From Delhi, take a day trip to Agra, home to the iconic Taj Mahal. Marvel at the beauty of this UNESCO World Heritage Site, known as one of the Seven Wonders of the World. Also, visit the Agra Fort, another architectural marvel.\n",
      "\n",
      "3. Jaipur: Head to Jaipur, the capital of Rajasthan, also known as the Pink City. Spend a day exploring the magnificent Amber Fort, City Palace, Hawa Mahal (Palace of Winds), and Jantar Mantar. Don't forget to indulge in Rajasthani cuisine and shop for traditional handicrafts.\n",
      "\n",
      "Please note that these are just a few suggestions, and India has many more incredible destinations to offer. It is advisable to plan your itinerary based on your interests and preferences. Additionally, consider the travel time between cities and the availability of flights or trains to optimize your three-day visit.\u001b[0m\n",
      "\n",
      "\u001b[1m> Finished chain.\u001b[0m\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'input': 'what can I visit in India in 3 days?',\n",
       " 'chat_history': [HumanMessage(content='what can I visit in India in 3 days?', additional_kwargs={}, example=False),\n",
       "  AIMessage(content=\"India is a vast and diverse country with numerous attractions to explore. While it may be challenging to cover all the highlights in just three days, here are some popular destinations that you can consider visiting:\\n\\n1. Delhi: Start your trip in the capital city of India, Delhi. Spend a day exploring the historical sites such as the Red Fort, Jama Masjid, Qutub Minar, and Humayun's Tomb. Don't miss a visit to the bustling markets of Chandni Chowk and indulge in delicious street food.\\n\\n2. Agra: From Delhi, take a day trip to Agra, home to the iconic Taj Mahal. Marvel at the beauty of this UNESCO World Heritage Site, known as one of the Seven Wonders of the World. Also, visit the Agra Fort, another architectural marvel.\\n\\n3. Jaipur: Head to Jaipur, the capital of Rajasthan, also known as the Pink City. Spend a day exploring the magnificent Amber Fort, City Palace, Hawa Mahal (Palace of Winds), and Jantar Mantar. Don't forget to indulge in Rajasthani cuisine and shop for traditional handicrafts.\\n\\nPlease note that these are just a few suggestions, and India has many more incredible destinations to offer. It is advisable to plan your itinerary based on your interests and preferences. Additionally, consider the travel time between cities and the availability of flights or trains to optimize your three-day visit.\", additional_kwargs={}, example=False)],\n",
       " 'output': \"India is a vast and diverse country with numerous attractions to explore. While it may be challenging to cover all the highlights in just three days, here are some popular destinations that you can consider visiting:\\n\\n1. Delhi: Start your trip in the capital city of India, Delhi. Spend a day exploring the historical sites such as the Red Fort, Jama Masjid, Qutub Minar, and Humayun's Tomb. Don't miss a visit to the bustling markets of Chandni Chowk and indulge in delicious street food.\\n\\n2. Agra: From Delhi, take a day trip to Agra, home to the iconic Taj Mahal. Marvel at the beauty of this UNESCO World Heritage Site, known as one of the Seven Wonders of the World. Also, visit the Agra Fort, another architectural marvel.\\n\\n3. Jaipur: Head to Jaipur, the capital of Rajasthan, also known as the Pink City. Spend a day exploring the magnificent Amber Fort, City Palace, Hawa Mahal (Palace of Winds), and Jantar Mantar. Don't forget to indulge in Rajasthani cuisine and shop for traditional handicrafts.\\n\\nPlease note that these are just a few suggestions, and India has many more incredible destinations to offer. It is advisable to plan your itinerary based on your interests and preferences. Additionally, consider the travel time between cities and the availability of flights or trains to optimize your three-day visit.\",\n",
       " 'intermediate_steps': []}"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "agent_executor({\"input\": \"what can I visit in India in 3 days?\"})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "\n",
      "\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n",
      "\u001b[32;1m\u001b[1;3m\n",
      "Invoking: `Search` with `{'query': 'current weather in Delhi'}`\n",
      "\n",
      "\n",
      "\u001b[0m\u001b[36;1m\u001b[1;3mCurrent Weather · 95°F Mostly sunny · RealFeel® 105°. Very Hot. RealFeel Guide. Very Hot. 101° to 107°. Caution advised. Danger of dehydration, heat stroke, heat ...\u001b[0m\u001b[32;1m\u001b[1;3mThe current weather in Delhi is 95°F (35°C) with mostly sunny conditions. The RealFeel® temperature is 105°F (41°C), indicating that it feels very hot. Caution is advised as there is a danger of dehydration, heat stroke, and heat-related issues. It is important to stay hydrated and take necessary precautions if you are in Delhi or planning to visit.\u001b[0m\n",
      "\n",
      "\u001b[1m> Finished chain.\u001b[0m\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'input': 'what is the current wheather in Delhi ?',\n",
       " 'chat_history': [HumanMessage(content='what can I visit in India in 3 days?', additional_kwargs={}, example=False),\n",
       "  AIMessage(content=\"India is a vast and diverse country with numerous attractions to explore. While it may be challenging to cover all the highlights in just three days, here are some popular destinations that you can consider visiting:\\n\\n1. Delhi: Start your trip in the capital city of India, Delhi. Spend a day exploring the historical sites such as the Red Fort, Jama Masjid, Qutub Minar, and Humayun's Tomb. Don't miss a visit to the bustling markets of Chandni Chowk and indulge in delicious street food.\\n\\n2. Agra: From Delhi, take a day trip to Agra, home to the iconic Taj Mahal. Marvel at the beauty of this UNESCO World Heritage Site, known as one of the Seven Wonders of the World. Also, visit the Agra Fort, another architectural marvel.\\n\\n3. Jaipur: Head to Jaipur, the capital of Rajasthan, also known as the Pink City. Spend a day exploring the magnificent Amber Fort, City Palace, Hawa Mahal (Palace of Winds), and Jantar Mantar. Don't forget to indulge in Rajasthani cuisine and shop for traditional handicrafts.\\n\\nPlease note that these are just a few suggestions, and India has many more incredible destinations to offer. It is advisable to plan your itinerary based on your interests and preferences. Additionally, consider the travel time between cities and the availability of flights or trains to optimize your three-day visit.\", additional_kwargs={}, example=False),\n",
       "  HumanMessage(content='what is the current wheather in India?', additional_kwargs={}, example=False),\n",
       "  AIMessage(content='', additional_kwargs={'function_call': {'name': 'Search', 'arguments': '{\\n  \"query\": \"current weather in India\"\\n}'}}, example=False),\n",
       "  FunctionMessage(content='Ahmedabad 89° Bengaluru 86° Bhopal 84° Chandigarh 91° Chennai 91° Delhi 97° Dispur 88° Faridabad 94° Guwahati 88° Jaipur 93° Kolkata 95° Lucknow 94° ...', additional_kwargs={}, name='Search'),\n",
       "  AIMessage(content=\"I apologize, but I couldn't find the specific current weather information for India. The weather conditions can vary significantly across different regions of the country. It is recommended to check a reliable weather website or use a weather app to get the most up-to-date and accurate information about the weather in specific cities or regions of India.\", additional_kwargs={}, example=False),\n",
       "  HumanMessage(content='what is the current wheather in Delhi ?', additional_kwargs={}, example=False),\n",
       "  AIMessage(content='', additional_kwargs={'function_call': {'name': 'Search', 'arguments': '{\\n  \"query\": \"current weather in Delhi\"\\n}'}}, example=False),\n",
       "  FunctionMessage(content='Current Weather · 95°F Mostly sunny · RealFeel® 105°. Very Hot. RealFeel Guide. Very Hot. 101° to 107°. Caution advised. Danger of dehydration, heat stroke, heat ...', additional_kwargs={}, name='Search'),\n",
       "  AIMessage(content='The current weather in Delhi is 95°F (35°C) with mostly sunny conditions. The RealFeel® temperature is 105°F (41°C), indicating that it feels very hot. Caution is advised as there is a danger of dehydration, heat stroke, and heat-related issues. It is important to stay hydrated and take necessary precautions if you are in Delhi or planning to visit.', additional_kwargs={}, example=False)],\n",
       " 'output': 'The current weather in Delhi is 95°F (35°C) with mostly sunny conditions. The RealFeel® temperature is 105°F (41°C), indicating that it feels very hot. Caution is advised as there is a danger of dehydration, heat stroke, and heat-related issues. It is important to stay hydrated and take necessary precautions if you are in Delhi or planning to visit.',\n",
       " 'intermediate_steps': [(_FunctionsAgentAction(tool='Search', tool_input={'query': 'current weather in Delhi'}, log=\"\\nInvoking: `Search` with `{'query': 'current weather in Delhi'}`\\n\\n\\n\", message_log=[AIMessage(content='', additional_kwargs={'function_call': {'name': 'Search', 'arguments': '{\\n  \"query\": \"current weather in Delhi\"\\n}'}}, example=False)]),\n",
       "   'Current Weather · 95°F Mostly sunny · RealFeel® 105°. Very Hot. RealFeel Guide. Very Hot. 101° to 107°. Caution advised. Danger of dehydration, heat stroke, heat ...')]}"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "agent_executor({\"input\": \"what is the current wheather in Delhi ?\"})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "\n",
      "\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n",
      "\u001b[32;1m\u001b[1;3m\n",
      "Invoking: `italy_travel` with `{'query': 'main attractions in Italy'}`\n",
      "\n",
      "\n",
      "\u001b[0m\u001b[33;1m\u001b[1;3m[Document(page_content='ITALY\\nMINUBE TRAVEL GUIDE\\nThe best must-see places for your travels, all\\ndiscovered by real minube users. Enjoy!', metadata={'source': 'italy_travel.pdf', 'page': 0}), Document(page_content='What to see\\n in Italy\\nPage 10\\n58\\nGardens\\nParco Sempione\\n \\nPatricia M. Gómez:\\n \\nThis is one of the most important\\nparks in Milan. \\nIt was wonderful to visit it this winter all\\ncovered in snow and then this spring for our first \"picnic\". The\\npark is very well kept and clean. \\nYou can easily go to\\nworkout, walk or just have a little taste of green space in this\\ncity, which can sometimes be gray. \\n☎\\n 390 277 404 343\\n - \\nPiazza Castello, 20121 Milan, Italy, \\nMilan\\n59\\nExhibitions\\nGulf of Naples\\n \\nCarlos Millán Gómez:\\n \\nIs there anywhere in the world\\nmore beautiful than the Gulf of Naples? I would say no. It is\\nthe very center of Paradise (perhaps it\\'s also by the door of\\nhell, yes, because Mount Vesuvius could erupt at any time).\\nThe Gulf smells like sea, lemon, fish, tomato ... and also\\nsounds wonderful, due to Naples\\' Italian music. \"O sole mio\",\\n\"Torna Surriento\", \"Questa picolissima serenade\" ... Want to\\nknow more about Neapolitan music? Well, come here, turn\\nthe speakers up and enjoy. http://bit.ly/qOEjiU \\nNapoli, \\nNaples\\n60\\nHistorical Monuments\\nJuliet\\'s House (Casa di Giulietta)\\n \\nMaría Carmen García Moraleda:\\n \\nVerona is a pleasant\\nplace. The city itself is very nice and there is romance added\\nthanks to the story of Romeo and Juliet, although the truth is\\nthat now it is not very touristy. \\nAlthough if really what you\\nwant is love, poetry and verse, its marvellous. \\n \\nmaya menozzi:\\n \\nit’s lovely to see lots of people writing', metadata={'source': 'italy_travel.pdf', 'page': 10}), Document(page_content=\"fossis:\\n \\nMy experience was amazing. I took a trip through\\nItaly starting in Florence and I'm still amazed at how beautiful\\nit was. I didn't expect it. I recommend that if you go to Italy,\\npass through Florence and to the Piazzale Michelangelo at\\nnight. You won't be sorry. It's beautiful, especially the view of\\nFlorence since you see everything from here. All my best!\\nPiazzale Michelangelo, \\nFlorence\", metadata={'source': 'italy_travel.pdf', 'page': 6}), Document(page_content=\"What to see\\n in Italy\\nPage 4\\nTrevi Fountain \\nTrotamundos:\\n The Trevi Fountain has its origins in the year 19BC when a freshwater spring was discovered, supposedly\\nwith the help of a Virgin. The discovery of this spring led Romans to build an aqueduct which, as was the tradition of the time,\\nended with a fountain. And so the Trevi Fountain was built. \\nThe monumental fountain we admire today was built in the 18th\\ncentury by an obscure character named Nicola Salvi. It took 30 years to built and ended up ruining Salvi's health. He died unable\\nto undertake other projects and without seeing his beautiful fountain completed (the work was finished by Pietro Bracci). One of\\nthe Trevi Fountain's most outstanding features is the contrast between the fountain's overwhelming grandeur and its location amid\\nnarrow alleyways and tiny squares. It was intentionally designed to elicit a surprise from tourists, most of whom are no doubt\\ndeeply impressed when they come face to face with it. \\nWhat I want to talk about, though, are the statues: at the top, the papal\\nshield stands between two winged figures playing trumpets. Below, there are sculptures representing the four seasons and the\\ncyclical nature of time. On either side of the main figure, there are two reliefs that depict the story of Agrippa’s soldiers discovering\\nthe spring with a dowsing rod and Agrippa ordering the construction of the aqueduct. \\nTwo other large statues tell of the benefits of\", metadata={'source': 'italy_travel.pdf', 'page': 4})]\u001b[0m\u001b[32;1m\u001b[1;3mHere are some suggestions for main attractions in Italy:\n",
      "\n",
      "1. Parco Sempione, Milan: This is one of the most important parks in Milan. It offers a green space in the city where you can relax, workout, or take a leisurely walk. The park is well-maintained and clean.\n",
      "\n",
      "2. Gulf of Naples: The Gulf of Naples is considered one of the most beautiful places in the world. It offers stunning views, a pleasant sea breeze, and the aroma of lemon, fish, and tomato. Naples, the city by the Gulf, is known for its Italian music and is a great place to explore.\n",
      "\n",
      "3. Juliet's House (Casa di Giulietta), Verona: Verona is a charming city with a romantic atmosphere, thanks to the story of Romeo and Juliet. Although it may not be as touristy as before, the city still exudes a sense of love, poetry, and verse. Juliet's House is a popular attraction for visitors.\n",
      "\n",
      "4. Piazzale Michelangelo, Florence: Located in Florence, Piazzale Michelangelo offers a breathtaking view of the city. It is especially beautiful to visit at night when you can see the entire city illuminated. The view from here is truly mesmerizing.\n",
      "\n",
      "5. Trevi Fountain, Rome: The Trevi Fountain in Rome is a monumental fountain that dates back to the 18th century. It is known for its grandeur and impressive sculptures. The fountain is located in narrow alleyways and tiny squares, creating a surprise for visitors.\n",
      "\n",
      "Please note that these are just a few suggestions, and Italy has countless other attractions to explore. It is advisable to plan your itinerary based on your interests and preferences.\u001b[0m\n",
      "\n",
      "\u001b[1m> Finished chain.\u001b[0m\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'input': \"I'm travelling to Italy, can you give me some suggestions of the main attractions?\",\n",
       " 'chat_history': [HumanMessage(content='what is the current wheather in India?', additional_kwargs={}, example=False),\n",
       "  AIMessage(content='', additional_kwargs={'function_call': {'name': 'Search', 'arguments': '{\\n  \"query\": \"current weather in India\"\\n}'}}, example=False),\n",
       "  FunctionMessage(content='Ahmedabad 89° Bengaluru 86° Bhopal 84° Chandigarh 91° Chennai 91° Delhi 97° Dispur 88° Faridabad 94° Guwahati 88° Jaipur 93° Kolkata 95° Lucknow 94° ...', additional_kwargs={}, name='Search'),\n",
       "  AIMessage(content=\"I apologize, but I couldn't find the specific current weather information for India. The weather conditions can vary significantly across different regions of the country. It is recommended to check a reliable weather website or use a weather app to get the most up-to-date and accurate information about the weather in specific cities or regions of India.\", additional_kwargs={}, example=False),\n",
       "  HumanMessage(content='what is the current wheather in Delhi ?', additional_kwargs={}, example=False),\n",
       "  AIMessage(content='', additional_kwargs={'function_call': {'name': 'Search', 'arguments': '{\\n  \"query\": \"current weather in Delhi\"\\n}'}}, example=False),\n",
       "  FunctionMessage(content='Current Weather · 95°F Mostly sunny · RealFeel® 105°. Very Hot. RealFeel Guide. Very Hot. 101° to 107°. Caution advised. Danger of dehydration, heat stroke, heat ...', additional_kwargs={}, name='Search'),\n",
       "  AIMessage(content='The current weather in Delhi is 95°F (35°C) with mostly sunny conditions. The RealFeel® temperature is 105°F (41°C), indicating that it feels very hot. Caution is advised as there is a danger of dehydration, heat stroke, and heat-related issues. It is important to stay hydrated and take necessary precautions if you are in Delhi or planning to visit.', additional_kwargs={}, example=False),\n",
       "  HumanMessage(content=\"I'm travelling to Italy, can you give me some suggestions of the main attractions?\", additional_kwargs={}, example=False),\n",
       "  AIMessage(content='', additional_kwargs={'function_call': {'name': 'italy_travel', 'arguments': '{\\n  \"query\": \"main attractions in Italy\"\\n}'}}, example=False),\n",
       "  FunctionMessage(content='[Document(page_content=\\'ITALY\\\\nMINUBE TRAVEL GUIDE\\\\nThe best must-see places for your travels, all\\\\ndiscovered by real minube users. Enjoy!\\', metadata={\\'source\\': \\'italy_travel.pdf\\', \\'page\\': 0}), Document(page_content=\\'What to see\\\\n in Italy\\\\nPage 10\\\\n58\\\\nGardens\\\\nParco Sempione\\\\n \\\\nPatricia M. Gómez:\\\\n \\\\nThis is one of the most important\\\\nparks in Milan. \\\\nIt was wonderful to visit it this winter all\\\\ncovered in snow and then this spring for our first \"picnic\". The\\\\npark is very well kept and clean. \\\\nYou can easily go to\\\\nworkout, walk or just have a little taste of green space in this\\\\ncity, which can sometimes be gray. \\\\n☎\\\\n 390 277 404 343\\\\n - \\\\nPiazza Castello, 20121 Milan, Italy, \\\\nMilan\\\\n59\\\\nExhibitions\\\\nGulf of Naples\\\\n \\\\nCarlos Millán Gómez:\\\\n \\\\nIs there anywhere in the world\\\\nmore beautiful than the Gulf of Naples? I would say no. It is\\\\nthe very center of Paradise (perhaps it\\\\\\'s also by the door of\\\\nhell, yes, because Mount Vesuvius could erupt at any time).\\\\nThe Gulf smells like sea, lemon, fish, tomato ... and also\\\\nsounds wonderful, due to Naples\\\\\\' Italian music. \"O sole mio\",\\\\n\"Torna Surriento\", \"Questa picolissima serenade\" ... Want to\\\\nknow more about Neapolitan music? Well, come here, turn\\\\nthe speakers up and enjoy. http://bit.ly/qOEjiU \\\\nNapoli, \\\\nNaples\\\\n60\\\\nHistorical Monuments\\\\nJuliet\\\\\\'s House (Casa di Giulietta)\\\\n \\\\nMaría Carmen García Moraleda:\\\\n \\\\nVerona is a pleasant\\\\nplace. The city itself is very nice and there is romance added\\\\nthanks to the story of Romeo and Juliet, although the truth is\\\\nthat now it is not very touristy. \\\\nAlthough if really what you\\\\nwant is love, poetry and verse, its marvellous. \\\\n \\\\nmaya menozzi:\\\\n \\\\nit’s lovely to see lots of people writing\\', metadata={\\'source\\': \\'italy_travel.pdf\\', \\'page\\': 10}), Document(page_content=\"fossis:\\\\n \\\\nMy experience was amazing. I took a trip through\\\\nItaly starting in Florence and I\\'m still amazed at how beautiful\\\\nit was. I didn\\'t expect it. I recommend that if you go to Italy,\\\\npass through Florence and to the Piazzale Michelangelo at\\\\nnight. You won\\'t be sorry. It\\'s beautiful, especially the view of\\\\nFlorence since you see everything from here. All my best!\\\\nPiazzale Michelangelo, \\\\nFlorence\", metadata={\\'source\\': \\'italy_travel.pdf\\', \\'page\\': 6}), Document(page_content=\"What to see\\\\n in Italy\\\\nPage 4\\\\nTrevi Fountain \\\\nTrotamundos:\\\\n The Trevi Fountain has its origins in the year 19BC when a freshwater spring was discovered, supposedly\\\\nwith the help of a Virgin. The discovery of this spring led Romans to build an aqueduct which, as was the tradition of the time,\\\\nended with a fountain. And so the Trevi Fountain was built. \\\\nThe monumental fountain we admire today was built in the 18th\\\\ncentury by an obscure character named Nicola Salvi. It took 30 years to built and ended up ruining Salvi\\'s health. He died unable\\\\nto undertake other projects and without seeing his beautiful fountain completed (the work was finished by Pietro Bracci). One of\\\\nthe Trevi Fountain\\'s most outstanding features is the contrast between the fountain\\'s overwhelming grandeur and its location amid\\\\nnarrow alleyways and tiny squares. It was intentionally designed to elicit a surprise from tourists, most of whom are no doubt\\\\ndeeply impressed when they come face to face with it. \\\\nWhat I want to talk about, though, are the statues: at the top, the papal\\\\nshield stands between two winged figures playing trumpets. Below, there are sculptures representing the four seasons and the\\\\ncyclical nature of time. On either side of the main figure, there are two reliefs that depict the story of Agrippa’s soldiers discovering\\\\nthe spring with a dowsing rod and Agrippa ordering the construction of the aqueduct. \\\\nTwo other large statues tell of the benefits of\", metadata={\\'source\\': \\'italy_travel.pdf\\', \\'page\\': 4})]', additional_kwargs={}, name='italy_travel'),\n",
       "  AIMessage(content=\"Here are some suggestions for main attractions in Italy:\\n\\n1. Parco Sempione, Milan: This is one of the most important parks in Milan. It offers a green space in the city where you can relax, workout, or take a leisurely walk. The park is well-maintained and clean.\\n\\n2. Gulf of Naples: The Gulf of Naples is considered one of the most beautiful places in the world. It offers stunning views, a pleasant sea breeze, and the aroma of lemon, fish, and tomato. Naples, the city by the Gulf, is known for its Italian music and is a great place to explore.\\n\\n3. Juliet's House (Casa di Giulietta), Verona: Verona is a charming city with a romantic atmosphere, thanks to the story of Romeo and Juliet. Although it may not be as touristy as before, the city still exudes a sense of love, poetry, and verse. Juliet's House is a popular attraction for visitors.\\n\\n4. Piazzale Michelangelo, Florence: Located in Florence, Piazzale Michelangelo offers a breathtaking view of the city. It is especially beautiful to visit at night when you can see the entire city illuminated. The view from here is truly mesmerizing.\\n\\n5. Trevi Fountain, Rome: The Trevi Fountain in Rome is a monumental fountain that dates back to the 18th century. It is known for its grandeur and impressive sculptures. The fountain is located in narrow alleyways and tiny squares, creating a surprise for visitors.\\n\\nPlease note that these are just a few suggestions, and Italy has countless other attractions to explore. It is advisable to plan your itinerary based on your interests and preferences.\", additional_kwargs={}, example=False)],\n",
       " 'output': \"Here are some suggestions for main attractions in Italy:\\n\\n1. Parco Sempione, Milan: This is one of the most important parks in Milan. It offers a green space in the city where you can relax, workout, or take a leisurely walk. The park is well-maintained and clean.\\n\\n2. Gulf of Naples: The Gulf of Naples is considered one of the most beautiful places in the world. It offers stunning views, a pleasant sea breeze, and the aroma of lemon, fish, and tomato. Naples, the city by the Gulf, is known for its Italian music and is a great place to explore.\\n\\n3. Juliet's House (Casa di Giulietta), Verona: Verona is a charming city with a romantic atmosphere, thanks to the story of Romeo and Juliet. Although it may not be as touristy as before, the city still exudes a sense of love, poetry, and verse. Juliet's House is a popular attraction for visitors.\\n\\n4. Piazzale Michelangelo, Florence: Located in Florence, Piazzale Michelangelo offers a breathtaking view of the city. It is especially beautiful to visit at night when you can see the entire city illuminated. The view from here is truly mesmerizing.\\n\\n5. Trevi Fountain, Rome: The Trevi Fountain in Rome is a monumental fountain that dates back to the 18th century. It is known for its grandeur and impressive sculptures. The fountain is located in narrow alleyways and tiny squares, creating a surprise for visitors.\\n\\nPlease note that these are just a few suggestions, and Italy has countless other attractions to explore. It is advisable to plan your itinerary based on your interests and preferences.\",\n",
       " 'intermediate_steps': [(_FunctionsAgentAction(tool='italy_travel', tool_input={'query': 'main attractions in Italy'}, log=\"\\nInvoking: `italy_travel` with `{'query': 'main attractions in Italy'}`\\n\\n\\n\", message_log=[AIMessage(content='', additional_kwargs={'function_call': {'name': 'italy_travel', 'arguments': '{\\n  \"query\": \"main attractions in Italy\"\\n}'}}, example=False)]),\n",
       "   [Document(page_content='ITALY\\nMINUBE TRAVEL GUIDE\\nThe best must-see places for your travels, all\\ndiscovered by real minube users. Enjoy!', metadata={'source': 'italy_travel.pdf', 'page': 0}),\n",
       "    Document(page_content='What to see\\n in Italy\\nPage 10\\n58\\nGardens\\nParco Sempione\\n \\nPatricia M. Gómez:\\n \\nThis is one of the most important\\nparks in Milan. \\nIt was wonderful to visit it this winter all\\ncovered in snow and then this spring for our first \"picnic\". The\\npark is very well kept and clean. \\nYou can easily go to\\nworkout, walk or just have a little taste of green space in this\\ncity, which can sometimes be gray. \\n☎\\n 390 277 404 343\\n - \\nPiazza Castello, 20121 Milan, Italy, \\nMilan\\n59\\nExhibitions\\nGulf of Naples\\n \\nCarlos Millán Gómez:\\n \\nIs there anywhere in the world\\nmore beautiful than the Gulf of Naples? I would say no. It is\\nthe very center of Paradise (perhaps it\\'s also by the door of\\nhell, yes, because Mount Vesuvius could erupt at any time).\\nThe Gulf smells like sea, lemon, fish, tomato ... and also\\nsounds wonderful, due to Naples\\' Italian music. \"O sole mio\",\\n\"Torna Surriento\", \"Questa picolissima serenade\" ... Want to\\nknow more about Neapolitan music? Well, come here, turn\\nthe speakers up and enjoy. http://bit.ly/qOEjiU \\nNapoli, \\nNaples\\n60\\nHistorical Monuments\\nJuliet\\'s House (Casa di Giulietta)\\n \\nMaría Carmen García Moraleda:\\n \\nVerona is a pleasant\\nplace. The city itself is very nice and there is romance added\\nthanks to the story of Romeo and Juliet, although the truth is\\nthat now it is not very touristy. \\nAlthough if really what you\\nwant is love, poetry and verse, its marvellous. \\n \\nmaya menozzi:\\n \\nit’s lovely to see lots of people writing', metadata={'source': 'italy_travel.pdf', 'page': 10}),\n",
       "    Document(page_content=\"fossis:\\n \\nMy experience was amazing. I took a trip through\\nItaly starting in Florence and I'm still amazed at how beautiful\\nit was. I didn't expect it. I recommend that if you go to Italy,\\npass through Florence and to the Piazzale Michelangelo at\\nnight. You won't be sorry. It's beautiful, especially the view of\\nFlorence since you see everything from here. All my best!\\nPiazzale Michelangelo, \\nFlorence\", metadata={'source': 'italy_travel.pdf', 'page': 6}),\n",
       "    Document(page_content=\"What to see\\n in Italy\\nPage 4\\nTrevi Fountain \\nTrotamundos:\\n The Trevi Fountain has its origins in the year 19BC when a freshwater spring was discovered, supposedly\\nwith the help of a Virgin. The discovery of this spring led Romans to build an aqueduct which, as was the tradition of the time,\\nended with a fountain. And so the Trevi Fountain was built. \\nThe monumental fountain we admire today was built in the 18th\\ncentury by an obscure character named Nicola Salvi. It took 30 years to built and ended up ruining Salvi's health. He died unable\\nto undertake other projects and without seeing his beautiful fountain completed (the work was finished by Pietro Bracci). One of\\nthe Trevi Fountain's most outstanding features is the contrast between the fountain's overwhelming grandeur and its location amid\\nnarrow alleyways and tiny squares. It was intentionally designed to elicit a surprise from tourists, most of whom are no doubt\\ndeeply impressed when they come face to face with it. \\nWhat I want to talk about, though, are the statues: at the top, the papal\\nshield stands between two winged figures playing trumpets. Below, there are sculptures representing the four seasons and the\\ncyclical nature of time. On either side of the main figure, there are two reliefs that depict the story of Agrippa’s soldiers discovering\\nthe spring with a dowsing rod and Agrippa ordering the construction of the aqueduct. \\nTwo other large statues tell of the benefits of\", metadata={'source': 'italy_travel.pdf', 'page': 4})])]}"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "agent_executor({\"input\": \"I'm travelling to Italy, can you give me some suggestions of the main attractions?\"})"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.9"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
